package com.neardrug.controller;

import com.neardrug.common.Result;
import com.neardrug.services.ApiResultService;
import com.neardrug.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "API返回结果相关")
@RequestMapping("/apiResult")
@Slf4j
public class ApiResultController {

    @Autowired
    private ApiResultService apiResultService;

    @GetMapping("/markdown/{taskId}")
    @ApiOperation("根据任务id查询markdown结果")
    public Result getMarkdown(@PathVariable Integer taskId){
        MarkdownResultVO markdownResultVO=apiResultService.getMarkdownByTaskId(taskId);
        return Result.success(markdownResultVO);
    }

    @GetMapping("/record/{taskId}")
    @ApiOperation("根据任务id查询著录结果")
    public Result getRecord(@PathVariable Integer taskId){
        RecordVO recordVO=apiResultService.getRecordByTaskId(taskId);
        return Result.success(recordVO);
    }

    @GetMapping("/examples/{taskId}")
    @ApiOperation("根据任务id查询合成过程")
    public Result getExamples(@PathVariable Integer taskId){
        ExamplesVO examplesVO=apiResultService.getExamplesByTaskId(taskId);
        return Result.success(examplesVO);
    }

    @GetMapping("/images/{taskId}")
    @ApiOperation("根据任务id查询图片页面数据")
    public Result getImages(@PathVariable Integer taskId){
        ImagesVO imagesVO=apiResultService.getImagesByTaskId(taskId);
        return Result.success(imagesVO);
    }

    @GetMapping("/form/{taskId}")
    @ApiOperation("根据任务id查询表格页面数据")
    public Result getForm(@PathVariable Integer taskId){
        FormVO formVO=apiResultService.getFormByTaskId(taskId);
        return Result.success(formVO);
    }

}
